<?php
if(!interface_exists('XResponse', false)){
	require_once(XFRAMEWORK_DIR.'/core/mvc/http/XResponse.php');
}
class XServletResponse implements XResponse{
	private static $instance = null;
	
	private function __construct(){
		
	}
	
	/**
	 * @return XServletResponse
	 */		
	static function singleton() {
		if (!self::$instance) {
			self::$instance = new self;
		}
		return self::$instance;
	}
		
	public function redirect($url = null){
		$location = preg_replace("/^[\\|\/]+/i", '/', $url);
		if(empty($url) || $url == '/'){
			$location = '/';
		}
		if(!headers_sent()){		
			header('location:'.$location);
			exit();
		}
	}
}
?>